﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SchoolManagementSystem.Controls;
using CoreData;
namespace SchoolManagementSystem.Details
{
    public partial class StockMethodUC : DetailUC
    {
        //string type;
        public StockMethodUC()
        {
            InitializeComponent();
            //this.type = type;
            //if (type == "IN")
            //{
                this.ObjectName = "phương thức nhập - xuất";
                this.Code = "StockMethod";
                this.Type=new Stock_Method();
                    //else {
            //    this.ObjectName = "phương thức nhập";
            //    this.Code = "StockMethodIn";
            //}
            
        }




        protected override long DetailDisplay()
        {
            Stock_Method data = new Stock_Method();
            if (ID > 0)
            {
                data = (Stock_Method)RegisterService.RegisterServices.StockMethodService.GetByID(ID);

            }

            txtname.Text = data.Name;
            txtnote.Text = data.Description;
            txtcode.Text = data.Code;
            comboBoxEdit1.Text = data.MethodType;
            ckactive.Checked = data.Active;

            return ID;

        }

        protected override long Save()
        {
            Stock_Method data = new Stock_Method();
            if (ID > 0)
            {
                data = (Stock_Method)RegisterService.RegisterServices.StockMethodService.GetByID(ID);

            }
            data.Code = txtcode.Text;
            data.Name = txtname.Text;
            data.Description = txtnote.Text;
            data.Active = ckactive.Checked;
            data.MethodType = comboBoxEdit1.Text;

            ID = RegisterService.RegisterServices.StockMethodService.Save(data);

            return ID;
        }


        public override bool Delete(long SelectedID)
        {

            return RegisterService.RegisterServices.StockMethodService.Delete(RegisterService.RegisterServices.StockMethodService.GetByID(SelectedID));

        }

        private void StockMethodUC_Load(object sender, EventArgs e)
        {
            AddTextChanged(groupControl1.Controls);
        }

       
    


    }
}
